home *** CD-ROM | disk | FTP | other *** search
- <HTML>
- <HEAD>
- <TITLE>Dynamic image map</TITLE>
- <SCRIPT LANGUAGE="JavaScript">
- var L=new layerTool();
- function layerTool()
- {
- if (navigator.appName=="Netscape")
- this.layerProp=navProp;
- else
- this.layerProp=exProp;
- }
- function exProp()
- {
- return document.all[arguments[arguments.length-1]].style;
- }
- function navProp()
- {
- retVal="";
- for (x=0;x<arguments.length;x++)
- {
- retVal+="document.layers[\'"+arguments[x]+"\']";
- if (x!=arguments.length-1)
- retVal+=".";
- }
- return eval(retVal);
- }
-
- p=new Array();
- p[0]=new Area(25,30,125,75,"http://www.corrosive.co.uk/");
- p[1]=new Area(5,125,130,175,"http://www.corrosive.co.uk/");
- p[2]=new Area(115,100,225,126,"http://www.corrosive.co.uk/");
-
- var cyc=0;
- m=new map("m","container","topLayer",p);
- function Area(X1,Y1,X2,Y2,url)
- {
- this.left=X1;
- this.top=Y1;
- this.right=X2;
- this.bottom=Y2;
- this.url=url;
- }
- function map(name,container,top,areas)
- {
- this.name=name;
- this.top=top;
- this.container=container;
- this.areas=areas;
- this.writeMap=writeMap;
- this. highlight=highlight;
- this.reset=reset;
- this.timeout=null;
- }
- function writeMap (mapName)
- {
- document.write("<map name="+mapName+">");
- for (x=0;x<this.areas.length;x++)
- {
- document.write("<area shape=\"RECT\" href='"+this.areas[x].url+"'
- onMouseOver='"+this.name+".highlight("+x+")' ");
- document.write("onMouseOut='"+this.name+".reset()' ");
- document.write("COORDS=\""+this.areas[x].left+","+this.areas[x].top+"
- "+this.areas[x].right+","+this.areas[x].bottom+"\">");
- }
- document.write("</map>");
- }
- function highlight(num)
- {
- clearTimeout(this.timeout);
- this.timeout=setTimeout(this.name+".reset()",5000);
- L.layerProp(this.container,this.top).visibility="visible";
- L.layerProp(this.container,this.top).clip.top=this.areas[num].top;
- L.layerProp(this.container,this.top).clip.left=this.areas[num].left;
- L.layerProp(this.container,this.top).clip.bottom=this.areas[num].bottom;
- L.layerProp(this.container,this.top).clip.right=this.areas[num].right;
- }
- function reset()
- {
- L.layerProp(this.container,this.top).visibility="hidden";
- }
- </SCRIPT>
- <STYLE TYPE="text/css">
- .maps{
- POSITION:absolute
- }
- #container{
- POSITION:relative
- }
- #topLayer{
- VISIBILITY:hidden
- }
- </STYLE>
- <SCRIPT>
- m.writeMap("myMap");
- </SCRIPT>
-
- </HEAD>
- <BODY BGCOLOR="#FFFFFF">
-
- <DIV ID="container">
- <DIV ID="bottomLayer" CLASS="maps">
- <IMG SRC="res/apple1.gif" USEMAP="#myMap" BORDER=0>
- </DIV>
- <DIV ID="topLayer" CLASS="maps">
- <IMG NAME=TEST SRC="res/apple2.gif" USEMAP="#myMap" BORDER=0>
- </DIV>
- </DIV>
-
- </BODY>
- </HTML>
-